/*
 *	main.h is part of Flight_Chess_Portable
 *	Copyright (C) 2008  Poison
 *
 *	This program is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 *	Class:			main
 *	Description:	
 *	Author:			Poison <hbpoison@gmail.com>
 *	Date Created:	2008-03-20
 */

#pragma once

#include "App.h"

class ExitCallback: public Callback
{
public:
	ExitCallback( const char * name, void * arg = NULL ) { create( name, arg ); }
	~ExitCallback() { drop(); }
	int reg();
protected:
	int CallbackFunction( int arg1, int arg2, void * arg );
};

class CallbackThread: public Thread
{
public:
	CallbackThread( bool free_on_term, const char * name, int priority = 0x11, int stack_size = 0xFA0, unsigned int attr = PSP_THREAD_ATTR_USER ) { create( free_on_term, name, priority, stack_size, attr ); }
	~CallbackThread() { drop(); }
protected:
	int ThreadEntry( int argc, void * argp );
private:
	ExitCallback * exit_cb;
};

class MainThread: public Thread
{
public:
	MainThread( bool free_on_term, const char * name, int priority = 0x10, int stack_size = 0x1000, unsigned int attr = PSP_THREAD_ATTR_USER ) { create( free_on_term, name, priority, stack_size, attr ); }
	~MainThread() { drop(); }
protected:
	int ThreadEntry( int argc, void * argp );
};

class MainApp: public App
{
public:
	int init( int argc, void * argv );
};
